var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        }),
    n =
        (this && this.__decorate) ||
        function (t, e, o, a) {
            var i,
                n = arguments.length,
                r = n < 3 ? e : null === a ? (a = Object.getOwnPropertyDescriptor(e, o)) : a;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (i = t[s]) && (r = (n < 3 ? i(r) : n > 3 ? i(e, o, r) : i(e, o)) || r);
            return n > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var r = cc._decorator,
    s = r.ccclass,
    c = r.property,
    p = r.executeInEditMode,
    l = r.requireComponent,
    d =
        (r.menu,
        (function (t) {
            i(e, t);
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                e._colors = [];
                e.count = 0;
                return e;
            }
            Object.defineProperty(e.prototype, "colors", {
                get: function () {
                    return this._colors;
                },
                set: function (t) {
                    this._colors = t;
                    this._updateColors();
                },
                enumerable: !1,
                configurable: !0
            });
            Object.defineProperty(e.prototype, "upView", {
                get: function () {
                    return !1;
                },
                set: function () {
                    this._updateColors();
                },
                enumerable: !1,
                configurable: !0
            });
            e.prototype.onEnable = function () {
                cc.director.once(cc.Director.EVENT_AFTER_DRAW, this._updateColors, this);
                this._updateColors();
                this.openDelay();
            };
            e.prototype.onDisable = function () {
                cc.director.off(cc.Director.EVENT_AFTER_DRAW, this._updateColors, this);
                this.node._renderFlag |= cc.RenderFlow.FLAG_COLOR;
            };
            e.prototype.upSetColor = function (t) {
                this._colors = t;
                this.openDelay();
            };
            e.prototype.openDelay = function () {
                var t = this;
                this.schedule(function () {
                    t._updateColors();
                    if (t.count > 100) {
                        t.count++;
                        t.unscheduleAllCallbacks();
                    }
                }, 0.1);
            };
            e.prototype._updateColors = function () {
                var t = this.getComponent(cc.RenderComponent);
                if (t) {
                    var e = t._assembler;
                    if (e instanceof cc.Assembler2D) {
                        var o = e._renderData.uintVDatas[0];
                        if (o)
                            for (
                                var a = this.node.color, i = e.floatsPerVert, n = 0, r = e.colorOffset, s = o.length;
                                r < s;
                                r += i
                            ) {
                                n++;
                                n %= this.colors.length;
                                o[r] = (this.colors[n] || a)._val;
                            }
                    }
                }
            };
            n([c], e.prototype, "_colors", void 0);
            n([c({type: [cc.Color]})], e.prototype, "colors", null);
            n([c({type: cc.Boolean, displayName: "刷新"})], e.prototype, "upView", null);
            return n([s, p, l(cc.RenderComponent)], e);
        })(cc.Component));
o.default = d;
